Conversation
| if not schema.with_standard: | ||
| raise HedFileError( | ||
| HedExceptions.ROOTED_TAG_INVALID, | ||
| HedExceptions.SCHEMA_ATTRIBUTE_INVALID, |
There was a problem hiding this comment.
Critical: AttributeError at runtime — HedExceptions.SCHEMA_ATTRIBUTE_INVALID does not exist on HedExceptions. That constant lives on SchemaAttributeErrors in hed/errors/error_types.py.
Either:
- Change to
HedExceptions.SCHEMA_LIBRARY_INVALID(consistent with the other rooted-tag errors below), or - Import
SchemaAttributeErrorsfromhed.errors.error_typesand useSchemaAttributeErrors.SCHEMA_ATTRIBUTE_INVALID.
| HedExceptions.SCHEMA_ATTRIBUTE_INVALID, | |
| HedExceptions.SCHEMA_LIBRARY_INVALID, |
| if not rooted_entry or rooted_entry.has_attribute(constants.HedKey.InLibrary): | ||
| raise HedFileError( | ||
| HedExceptions.ROOTED_TAG_DOES_NOT_EXIST, | ||
| HedExceptions.LIBRARY_SCHEMA_INVALID, |
There was a problem hiding this comment.
Critical: AttributeError at runtime — HedExceptions.LIBRARY_SCHEMA_INVALID does not exist. The constant is SCHEMA_LIBRARY_INVALID (note the word order).
| HedExceptions.LIBRARY_SCHEMA_INVALID, | |
| HedExceptions.SCHEMA_LIBRARY_INVALID, |
|
|
||
| # These are actual schema issues, not that the file cannot be found or parsed | ||
| SCHEMA_HEADER_MISSING = "SCHEMA_HEADER_INVALID" | ||
| SCHEMA_HEADER_INVALID = "SCHEMA_HEADER_INVALID" |
There was a problem hiding this comment.
Critical: Incomplete removal — AttributeError at runtime in three files
IN_LIBRARY_IN_UNMERGED and INVALID_LIBRARY_PREFIX were removed from HedExceptions, but they are still referenced in files not touched by this PR:
| File | Line | Removed constant |
|---|---|---|
hed/schema/schema_io/xml2schema.py |
351 | HedExceptions.IN_LIBRARY_IN_UNMERGED |
hed/schema/schema_io/df2schema.py |
278 | HedExceptions.IN_LIBRARY_IN_UNMERGED |
hed/schema/schema_io/wiki2schema.py |
612 | HedExceptions.IN_LIBRARY_IN_UNMERGED |
hed/schema/hed_schema.py |
426 | HedExceptions.INVALID_LIBRARY_PREFIX |
Each of those call sites needs to be updated to its replacement code (SCHEMA_LIBRARY_INVALID for IN_LIBRARY_IN_UNMERGED, and SCHEMA_LIBRARY_INVALID for INVALID_LIBRARY_PREFIX) before merging.
Review SummaryThis PR consolidates redundant Critical — will crash at runtime1. 2. 3.
All three need 4. Confirmed good fixes in this PR
The alias consolidation approach is correct; it just needs the four call sites above updated before merging. |
There was a problem hiding this comment.
Pull request overview
This PR appears to follow up on review feedback from #1247 by standardizing schema-related error codes/messages, cleaning up dead/commented code, and making a few small validator/analysis fixes.
Changes:
- Consolidates multiple schema/header/library error codes into fewer canonical
HedExceptionscodes and updates tests accordingly. - Refactors/cleans up validators and tools (e.g., precompiled column-ref regex, removes unused
make_path, removes commented code). - Fixes a few correctness issues in analysis/utilities (e.g., tag count merge bug, onset tolerance constant, error message typos).
Reviewed changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/schema/test_schema_wiki_fatal_errors.py | Updates expected fatal error codes for wiki schema header cases. |
| tests/schema/test_hed_schema_io.py | Updates prerelease-partner tests/docs to assert the new error code. |
| spec_tests/test_hed_cache.py | Updates expected exception code for invalid merged schema load cases. |
| hed/validator/util/group_util.py | Removes unused commented-out validator hooks. |
| hed/validator/spreadsheet_validator.py | Fixes onset tolerance constant to a small float tolerance. |
| hed/validator/sidecar_validator.py | Precompiles the column reference regex and reuses it. |
| hed/validator/def_validator.py | Removes commented-out unit validation code. |
| hed/tools/util/io_util.py | Removes the unused make_path helper. |
| hed/tools/bids/bids_dataset.py | Fixes an error message typo (extra }). |
| hed/tools/analysis/hed_type_factors.py | Normalizes factor encoding errors to raise HedFileError and fixes a doc typo. |
| hed/tools/analysis/hed_tag_counts.py | Fixes merge logic when summing per-value counts. |
| hed/tools/analysis/annotation_util.py | Removes large blocks of commented-out legacy helpers. |
| hed/tools/init.py | Stops exporting make_path (aligned with its removal). |
| hed/schema/schema_io/wiki2schema.py | Uses SCHEMA_HEADER_INVALID for missing/invalid header line. |
| hed/schema/schema_io/base2schema.py | Adjusts error codes for schema merge/load and rooted-tag validation paths. |
| hed/schema/schema_header_util.py | Improves library-name validation messages and aligns error codes. |
| hed/schema/hed_schema_group.py | Uses SCHEMA_LOAD_FAILED for duplicate namespace/prefix collisions. |
| hed/errors/exceptions.py | Removes legacy/alias exception constants in favor of canonical codes. |
| hed/errors/error_messages.py | Fixes missing trailing quote in formatted def/def-expand messages. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| if not schema.with_standard: | ||
| raise HedFileError( | ||
| HedExceptions.ROOTED_TAG_INVALID, | ||
| HedExceptions.SCHEMA_ATTRIBUTE_INVALID, |
There was a problem hiding this comment.
HedExceptions.SCHEMA_ATTRIBUTE_INVALID is referenced here, but HedExceptions (hed/errors/exceptions.py) does not define this constant. This will raise an AttributeError at runtime when a rooted tag is encountered. Either add SCHEMA_ATTRIBUTE_INVALID to HedExceptions or use an existing HedExceptions.* code that matches this condition (or switch this path to use the schema attribute error code source consistently).
| HedExceptions.SCHEMA_ATTRIBUTE_INVALID, | |
| HedExceptions.SCHEMA_LIBRARY_INVALID, |
| raise HedFileError( | ||
| HedExceptions.ROOTED_TAG_INVALID, | ||
| HedExceptions.SCHEMA_LIBRARY_INVALID, | ||
| f"Rooted tag '{tag_entry.short_tag_name}' is not a string.\"", |
There was a problem hiding this comment.
The error message string ends with an extra escaped quote (... is not a string."), which will produce a confusing message (trailing "). Remove the stray quote so the message is clean.
| f"Rooted tag '{tag_entry.short_tag_name}' is not a string.\"", | |
| f"Rooted tag '{tag_entry.short_tag_name}' is not a string.", |
| if not rooted_entry or rooted_entry.has_attribute(constants.HedKey.InLibrary): | ||
| raise HedFileError( | ||
| HedExceptions.ROOTED_TAG_DOES_NOT_EXIST, | ||
| HedExceptions.LIBRARY_SCHEMA_INVALID, |
There was a problem hiding this comment.
HedExceptions.LIBRARY_SCHEMA_INVALID is referenced here, but HedExceptions (hed/errors/exceptions.py) does not define this constant. This will raise an AttributeError at runtime. Use an existing error code (e.g., SCHEMA_LIBRARY_INVALID if appropriate) or define LIBRARY_SCHEMA_INVALID in HedExceptions.
| HedExceptions.LIBRARY_SCHEMA_INVALID, | |
| HedExceptions.SCHEMA_LIBRARY_INVALID, |
No description provided.